import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/constants/font_family.dart';
import 'package:flutter_eve_plugin/constants/font_weight.dart';
import 'package:flutter_eve_plugin/model/ye_xiu/checkpoint/stageinfo.dart';
import 'package:flutter_eve_plugin/model/ye_xiu/checkpoint/stages.dart';
import 'package:flutter_eve_plugin/utils/image_util.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';

class CheckpointDialogLeftTitleWidget extends StatelessWidget {
  final CheckpointStageInfo info;
  final CheckpointStageList item;
  const CheckpointDialogLeftTitleWidget({Key key, this.info, this.item})
      : super(key: key);

  //0 -- 未通关 10 -- C级 20 -- B级 30 -- A级 40 -- S级
  String buildLevelImage(CheckpointStageList item) {
    switch (item?.usrInfo?.stageGrade?.grade ?? 0) {
      case 0:
        return '';
      case 10:
        return 'checkpoint/icon_level_c@3x';
      case 20:
        return 'checkpoint/icon_level_b@3x';
      case 30:
        return 'checkpoint/icon_level_a@3x';
      case 40:
        return 'checkpoint/icon_level_s@3x';
      default:
        return '';
    }
  }

  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Container(
          width: setRatio(273),
          height: setRatio(48),
          decoration: BoxDecoration(
              image: DecorationImage(
                  image: AssetImage(imageUtilYeXiu(
                      'checkpoint/icon_dialog_title_left_bg@3x')))),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              SizedBox(
                width: setRatio(26),
              ),
              SizedBox(
                child: Text(
                  info?.stageBasics?.configInfo?.bossname ?? '',
                  style: TextStyle(
                    fontFamily: FontFamily.PMZD,
                    fontSize: setTextSp(22),
                    color: Color(0xFFFFFFFF),
                  ),
                  overflow: TextOverflow.ellipsis,
                ),
                width: setRatio(110),
              ),
              SizedBox(
                width: setRatio(43),
              ),
              Image.asset(
                imageUtilYeXiu(buildLevelImage(item)),
                width: setRatio(30),
                height: setRatio(30),
              ),
              Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    '当前得分',
                    style: TextStyle(
                        fontFamily: FontFamily.PINGFANG,
                        fontWeight: FontWeightCustom.PF_Medium,
                        fontSize: setRatio(10),
                        color: Color(0xFFFFFFFF)),
                  ),
                  Text(
                    '${item?.usrInfo?.stageGrade?.score ?? 0}',
                    style: TextStyle(
                        fontFamily: FontFamily.PMZD,
                        fontSize: setRatio(15),
                        color: Color(0xFFFFBF13)),
                  )
                ],
              )
            ],
          ),
        )
      ],
    );
  }
}
